﻿@model CodeCamp.Models.Home.HomeIndexViewModel
@{
    @* ViewBag.RegistrationUrl set in code - SetSharedViewBagProperties *@
    ViewBag.Greeting = "";
    ViewBag.Title = "";
    var indexPartial = "";
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName);
    }
    else
    {
        ViewBag.Title = "Code Camp";
    }
    if ((@Model == null) || (@Model.EventShortName == null) || (@Model.DefaultEventShortName == null))
    {
        ViewBag.Greeting = "";
    }
    else
    {
        if (@Model.EventIsPublic)
        {
            if (DateTime.Now < @Model.EventStartDate.AddDays(7))
            {
                ViewBag.Greeting = "Welcome to";
            }
            else
            {
                ViewBag.Greeting = "This was";
            }
        }
        else
        {
            ViewBag.Greeting = "(Not Public)";
        }
    }
    var displayDate = "";
    var displayLocation = "";
    if (@Model != null)
    {
        displayDate = @Model.DisplayDate;
        displayLocation = @Model.DisplayLocation;
        if (!string.IsNullOrWhiteSpace(@Model.EventShortName))
        {
            indexPartial = @Model.EventShortName + "/IndexPartial";
        }
    }
    if (string.IsNullOrWhiteSpace(indexPartial))
    {
        indexPartial = "DefaultIndexPartial";
    }
}

<h2>@ViewBag.Message</h2>
<h3>Home</h3>
  <h1>@ViewBag.Greeting @ViewBag.Title</h1>
  <h2>@displayDate</h2>
  <h3>@displayLocation</h3>
  <div style="margin-top: 1em;">
    @Html.Partial(@indexPartial, @Model)
  </div>

  @section sidebar {
    @Html.Partial("SidebarContentPartial")
  }